package com.sunshine.schedulegrid.config

import com.sunshine.schedulegrid.utils.DateUtils
import java.io.Serializable
import java.util.*
import kotlin.collections.ArrayList

/**
 * @author sunshine
 * @date 2020/8/29
 * 课程格子配置类
 * @see
 */

class ScheduleConfig : Serializable {

    companion object{

        //日程按时间模式展示
        const val TIME_MODE = 0

        //日程按课程模式展示
        const val LESSON_MODE = 1

        //按钮文字左上显示
        const val BUTTON_TEXT_START = 2

        //按钮文字居中显示
        const val BUTTON_TEXT_CENTER = 3

    }

    //一周显示的天数，true代表显示那天
    private var showDayOfWeek: ArrayList<Boolean> = ArrayList(Collections.nCopies(7, true))

    //日期栏高度
    private var dateHeight: Int = 150

    //左边节数或时间指示器宽度
    private var timeWidth: Int = 100

    //日程时按时间展示还是节数展示，默认为课程模式
    private var scheduleDisplayMode: Int = LESSON_MODE

    //课程模式下一节课的高度
    private var everyLessonHeight: Int = 250

    //日程间纵向间距
    private var heightDistant = 10

    //日程间横向间距
    private var widthDistant = 5

    //默认开学时间的long值
    private var startDate: Long = DateUtils.getStartDateLong()

    //是否显示非本周日程，默认为是
    private var showNotInThisWeek = true

    //按钮上是否显示教师信息
    private var showTeacher = true

    //按钮文字居中或者左上。默认左上
    private var buttonTextLocation: Int = BUTTON_TEXT_START

    //按钮文字内边距
    private var buttonTextPadding: Int = 10

    //按钮文字大小
    private var buttonTextSize: Float = 12.5f

    //按钮圆角
    private var buttonCornerRadius: Float = 10f

    //按钮透明度
    private var buttonAlpha: Int = 200

    //按钮文字颜色
    private var buttonTextColor: String = "#FFFFFF"

    //一天中最大的节数，用于时间栏，只在课程模式下生效
    private var lessonMaxCount: Int = 10

    //日期栏文字大小
    private var dateButtonTextSize = 12.5f

    //一个学期有几周。
    private var weekCount = 30

    //是否显示午休和晚休
    private var showRest: Boolean = false

    //第几节后午休。只对课程模式生效
    private var noonRest = 4

    //第几节后晚休。只对课程模式生效
    private var nightRest = 8

    /**
     * 获取一周显示几天
     * @see DateView
     * @see MainView
     * @return 一周显示天的数目
     * */
    fun showDaysCount(): Int {
        var count = 0
        showDayOfWeek.forEach {
            if (it) count++
        }
        return count
    }

    fun setShowDaysCount(list: ArrayList<Boolean>){
        showDayOfWeek = list
    }

    fun showDayOfWeek(): ArrayList<Boolean>{
        return showDayOfWeek
    }

    fun setShowDayOfWeek(showDayOfWeek: ArrayList<Boolean>){
        this.showDayOfWeek = showDayOfWeek
    }

    fun dateHeight(): Int{
        return dateHeight
    }

    fun setDateHeight(dateHeight: Int) {
        this.dateHeight = dateHeight
    }

    fun timeWidth(): Int{
        return timeWidth
    }

    fun setTimeWidth(timeWidth: Int) {
        this.timeWidth = timeWidth
    }

    fun scheduleDisplayMode(): Int {
        return scheduleDisplayMode
    }

    fun setScheduleDisplayMode(scheduleDisplayMode: Int) {
        this.scheduleDisplayMode = scheduleDisplayMode
    }

    fun everyLessonHeight(): Int {
        return everyLessonHeight
    }

    fun setEveryLessonHeight(everyLessonHeight: Int) {
        this.everyLessonHeight = everyLessonHeight
    }

    fun widthDistant(): Int {
        return widthDistant
    }

    fun setWidthDistant(widthDistant: Int) {
        this.widthDistant = widthDistant
    }

    fun heightDistant(): Int {
        return heightDistant
    }

    fun setHeightDistant(heightDistant: Int) {
        this.heightDistant = heightDistant
    }

    fun showNotInThisWeek(): Boolean{
        return showNotInThisWeek
    }

    fun setShowNotInThisWeek(showNotInThisWeek: Boolean) {
        this.showNotInThisWeek = showNotInThisWeek
    }

    fun startDate(): Long {
        return startDate
    }

    fun setStartDate(startDate: Long) {
        this.startDate = startDate
    }

    fun showTeacher(): Boolean{
        return showTeacher
    }

    fun setShowTeacher(showTeacher: Boolean) {
        this.showTeacher = showTeacher
    }

    fun buttonTextLocation(): Int {
        return buttonTextLocation
    }

    fun setButtonTextLocation(buttonTextLocation: Int) {
        this.buttonTextLocation = buttonTextLocation
    }

    fun buttonTextPadding(): Int{
        return buttonTextPadding
    }

    fun setButtonTextPadding(buttonTextPadding: Int) {
        this.buttonTextPadding = buttonTextPadding
    }

    fun buttonTextSize(): Float {
        return buttonTextSize
    }

    fun setButtonTextSize(buttonTextSize: Float) {
        this.buttonTextSize = buttonTextSize
    }

    fun buttonCornerRadius(): Float {
        return buttonCornerRadius
    }

    fun setButtonCornerRadius(buttonCornerRadius: Float) {
        this.buttonCornerRadius = buttonCornerRadius
    }

    fun buttonAlpha(): Int {
        return buttonAlpha
    }

    fun setButtonAlpha(buttonAlpha: Int) {
        this.buttonAlpha = buttonAlpha
    }

    fun buttonTextColor(): String {
        return buttonTextColor
    }

    fun setButtonTextColor(buttonTextColor: String) {
        this.buttonTextColor = buttonTextColor
    }

    //最大课程在显示午休和晚休情况会加2
    fun lessonMaxCount(): Int {
        return if (showRest) lessonMaxCount + 2 else lessonMaxCount
    }

    fun dateButtonTextSize(): Float {
        return dateButtonTextSize
    }

    fun setDateButtonTextSize(dateButtonTextSize: Float) {
        this.dateButtonTextSize = dateButtonTextSize
    }

    fun weekCount(): Int {
        return weekCount
    }

    fun setWeekCount(weekCount: Int) {
        this.weekCount = weekCount
    }

    fun showRest(): Boolean {
        return showRest
    }

    fun setShowRest(showRest: Boolean) {
        this.showRest = showRest
    }

    fun noonRest(): Int {
        return noonRest
    }

    fun setNoonRest(noonRest: Int) {
        this.noonRest = noonRest
    }

    fun nightRest(): Int {
        return nightRest
    }

    fun setNightRest(nightRest: Int) {
        this.nightRest = nightRest
    }

    /**
     * 获取今天是第几周
     */
    fun nowWeek(): Int {
        return DateUtils.getThisWeek()
    }
}